<?php

/*
 * Created on 08.01.2007
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 *
 * <example:bodyProcess></example:bodyProcess>
 */

m2import('phpinchains/psp/MethodTag.php');

class cms_getdescriptionbyidHandler extends phpinchains_psp_MethodTag {

    /**
     * Is a body tag (if false, body is ignored)
     */
    var $tagType = PSP_EMPTY_TAG;
    /**
     * Tag name in form namespace:tagname
     */
    var $tagName = 'cms:getdescriptionbyid';
    var $requiredAttributes = array(
        'id' => '\d+'
    );
    var $attributes = array(
        'var'
    );
    /**
     * Documents related to the one this method is used in
     *
     * @var array Related docs
     */
    private $dba;

    function doStartTag() {
        $ctx = base_ApplicationContext::getInstance();
        $env = $ctx->getEnvWrapper();
        $this->dba = $ctx->getAccessFactory()->getInstanceOf(base_AccessFactory::$CMS);
        $dctx = $ctx->getDocumentContext();
        $buildMode = $dctx->getBuildMode();
        $siteId = $dctx->getSiteId();
        $doc_id = $this->getAttribute('id');
        $this->related_docs[] = $doc_id;
        $doc = $dctx->getDocTree()->getByID($doc_id);
        if ($doc) {
            if ($this->getAttribute('var'))
                $this->actionform->set($this->getAttribute('var'), ($doc['descr']) ? $doc['descr'] : $doc['name']);
            else
                $this->out->write(($doc['descr']) ? $doc['descr'] : $doc['name']);
        }
        $this->registerRelatedDocuments($dctx);
        return PSP_SKIP_BODY;
    }

    function doEndTag() {
        return PSP_SKIP_BODY;
    }

}

?>